package com.zynn.common.core.utils;

import java.util.Random;

/**
 * 随即生产一定长度字符串
 *
 * @author 杨岳
 * @date 2018/7/30 17:27
 */
public class RandomStringUtils {
    private static final char[] legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
            .toCharArray();

    /**
     * 随即长度的字符串
     *
     * @param count 需要随即字符的长度
     * @return 生产的随即字符串
     */
    public static String randomString(int count) {
        Random random = new Random();
        String result = "";
        for (int i = 0; i < count; i++) {
            int o = random.nextInt(legalChars.length);
            result += legalChars[o];
        }
        return result;
    }
}
